<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>

<body>
  <script>
    //localStorage 存储  HTML5存储
    //不可以设置过期时间，需要手动删除
    //5M 左右的存储数据量
    //兼容IE8 以上的浏览器
    // 设置localStorage 
    localStorage.tizhong = 88;
    // localStorage.setItem(key,value) 设置localStorage的方法
    localStorage.setItem("xingzuo", "天蝎座")
    localStorage.setItem("shuxiang", "龙")
    // 不能直接存储和调用 数组和对象
    localStorage.arr = [1, 2, 3]
    // 获取localStorge 
    document.write(localStorage.xingzuo);
    document.write(localStorage.getItem("tizhong"))
    // 删除 localStorage.removeItem()
    localStorage.removeItem("shuxiang")
    //清空存储localStorage.clear()
    localStorage.clear()

  </script>
</body>

</html>